package com.hsy.baoinbao.modules.my.activity;

import android.os.Bundle;
import android.widget.TextView;

import com.android.volley.VolleyError;
import com.deparse.dpframe.utils.DPHttpUtil;
import com.deparse.dpframe.utils.DPLogUtil;
import com.hsy.baoinbao.R;
import com.hsy.baoinbao.common.Consts;
import com.hsy.baoinbao.modules.common.CommonBaseActivityWithSimpleActionBar;
import com.hsy.baoinbao.utils.CommonUtils;
import com.hsy.baoinbao.utils.HttpUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/3/23.
 */
public class AboutUsActivity extends CommonBaseActivityWithSimpleActionBar {
    private TextView person_about_us_name, person_about_us_content, person_about_us_date;
    private DPHttpUtil.HttpCallback httpCallBack = new DPHttpUtil.HttpCallback() {
        @Override
        public void onSuccess(int what, String response) {

            try {
                JSONObject result = new JSONObject(response);
                String name = result.optString("name");
                String context = result.optString("context");
                String date = result.optString("date");

                DPLogUtil.d(name);
                person_about_us_name.setText(name);
                person_about_us_content.setText(context);
                person_about_us_date.setText(date);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            CommonUtils.hideProgressDialog();
        }

        @Override
        public void onError(int what, int type, VolleyError error) {
            CommonUtils.hideProgressDialog();
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        setTitle("详情");
        person_about_us_name = F(R.id.person_about_us_name);
        person_about_us_content = F(R.id.person_about_us_content);
        person_about_us_date = F(R.id.person_about_us_date);
        CommonUtils.showProgressDialog(this);
        Map<String, String> data = new HashMap<>();
        data.put("token", CommonUtils.getToken(AboutUsActivity.this));
        HttpUtil.httpPostWithParams(this, 0, Consts.API_PERSON_ABOUT_US, data, httpCallBack);
    }
}
